<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>轮播图测试</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            text-align: center;
            margin-bottom: 40px;
        }
        .photo-carousel {
            border: 3px solid blue;
            margin: 20px auto;
            max-width: 800px;
        }
        .carousel-container {
            position: relative;
            width: 100%;
            height: 400px;
            border: 3px solid green;
            overflow: hidden;
        }
        .carousel-slides {
            width: 100%;
            height: 100%;
        }
        .carousel-slide {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            transition: opacity 0.5s ease;
        }
        .carousel-slide.active {
            opacity: 1;
            z-index: 1;
        }
        .carousel-slide:not(.active) {
            opacity: 0;
            z-index: 0;
        }
        .carousel-slide img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .carousel-caption {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 15px;
            text-align: center;
            font-size: 18px;
        }
        .carousel-control {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background-color: rgba(0, 0, 0, 0.5);
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
            z-index: 10;
            font-size: 24px;
        }
        .carousel-control.prev {
            left: 10px;
        }
        .carousel-control.next {
            right: 10px;
        }
        .carousel-indicators {
            text-align: center;
            margin-top: 20px;
        }
        .indicator {
            width: 15px;
            height: 15px;
            margin: 0 5px;
            background-color: #ddd;
            border: none;
            border-radius: 50%;
            cursor: pointer;
        }
        .indicator.active {
            background-color: #333;
        }
    </style>
</head>
<body>
    <h1>轮播图独立测试页面</h1>
    
    <div class="photo-carousel">
        <div class="carousel-container">
            <div class="carousel-slides">
                <div class="carousel-slide active">
                    <img src="/pages_paiqiu/about/carousel_images/teamphoto.png" alt="球队合影">
                    <div class="carousel-caption">球队合影</div>
                </div>
                <div class="carousel-slide">
                    <img src="/pages_paiqiu/about/carousel_images/training.png" alt="训练瞬间">
                    <div class="carousel-caption">训练瞬间</div>
                </div>
                <div class="carousel-slide">
                    <img src="/pages_paiqiu/about/carousel_images/game.png" alt="比赛精彩时刻">
                    <div class="carousel-caption">比赛精彩时刻</div>
                </div>
                <div class="carousel-slide">
                    <img src="/pages_paiqiu/about/carousel_images/trophy.png" alt="奖杯展示">
                    <div class="carousel-caption">奖杯展示</div>
                </div>
            </div>
            <button class="carousel-control prev" onclick="moveSlide(-1)">
                <i class="fas fa-chevron-left"></i>
            </button>
            <button class="carousel-control next" onclick="moveSlide(1)">
                <i class="fas fa-chevron-right"></i>
            </button>
        </div>
        <div class="carousel-indicators">
            <button class="indicator active" onclick="currentSlide(0)"></button>
            <button class="indicator" onclick="currentSlide(1)"></button>
            <button class="indicator" onclick="currentSlide(2)"></button>
            <button class="indicator" onclick="currentSlide(3)"></button>
        </div>
    </div>
    
    <script>
        let slideIndex = 0;
        let slideInterval;
        
        // 初始化轮播
        function initCarousel() {
            showSlides(slideIndex);
            startSlideTimer();
            
            // 鼠标悬停时暂停自动播放
            const carouselContainer = document.querySelector('.carousel-container');
            carouselContainer.addEventListener('mouseenter', () => {
                clearInterval(slideInterval);
                console.log('Auto-play paused');
            });
            
            // 鼠标离开时恢复自动播放
            carouselContainer.addEventListener('mouseleave', startSlideTimer);
        }
        
        // 移动到上一张或下一张幻灯片
        function moveSlide(n) {
            clearInterval(slideInterval);
            showSlides(slideIndex += n);
            startSlideTimer();
            console.log('Moved to slide:', slideIndex);
        }
        
        // 跳转到指定幻灯片
        function currentSlide(n) {
            clearInterval(slideInterval);
            showSlides(slideIndex = n);
            startSlideTimer();
            console.log('Current slide:', slideIndex);
        }
        
        // 显示幻灯片
        function showSlides(n) {
            let i;
            const slides = document.querySelectorAll('.carousel-slide');
            const indicators = document.querySelectorAll('.indicator');
            
            if (n >= slides.length) {slideIndex = 0}
            if (n < 0) {slideIndex = slides.length - 1}
            
            // 切换幻灯片显示状态
            for (i = 0; i < slides.length; i++) {
                slides[i].classList.remove('active');
            }
            
            // 切换指示器激活状态
            for (i = 0; i < indicators.length; i++) {
                indicators[i].classList.remove('active');
            }
            
            slides[slideIndex].classList.add('active');
            indicators[slideIndex].classList.add('active');
            console.log('Showing slide:', slideIndex);
        }
        
        // 启动自动播放计时器
        function startSlideTimer() {
            slideInterval = setInterval(() => {
                moveSlide(1);
            }, 5000); // 5秒切换一次
            console.log('Auto-play started');
        }
        
        // 页面加载完成后初始化轮播
        document.addEventListener('DOMContentLoaded', function() {
            console.log('DOMContentLoaded event triggered');
            initCarousel();
            
            // 调试代码：检查所有轮播图片路径
            const slides = document.querySelectorAll('.carousel-slide');
            slides.forEach((slide, index) => {
                const img = slide.querySelector('img');
                if (img) {
                    console.log(`Slide ${index} image URL:`, img.src);
                    
                    // 尝试直接加载图片进行测试
                    const testImage = new Image();
                    testImage.src = img.src;
                    testImage.onload = function() {
                        console.log(`Image ${img.src} loaded successfully`);
                    };
                    testImage.onerror = function() {
                        console.error(`Failed to load image: ${img.src}`);
                    };
                }
            });
        });
    </script>
</body>
</html>